<script setup>
import { ref, onMounted, nextTick } from "vue";
import SvgIcon from "@/components/svgIcon/index.vue";
import FormLogin from "./components/formLogin.vue";
import Carousel from "./components/Carousel.vue";
import QrcodeLogin from "./components/QrcodeLogin.vue";

const loginType = ref(true);

const changeLoginType = () => {
  loginType.value = !loginType.value;
};
</script>

<template>
  <div class="login-container">
    <div class="header">
      <img class="logo-img" src="@/assets/layout_logo.png" />
      <span class="slogn">
        {{ $t("web.slogn") }}
      </span>
    </div>
    <div class="body">
      <div class="carousel">
        <Carousel />
      </div>
      <div class="login-box">
        <div class="title-box">
          <h2>
            {{ $t("welcome") + $t("login.text") }}
          </h2>
          <a-tooltip class="change-btn" @click="changeLoginType">
            <template #title>
              {{ $t("login.changeMode") }}
            </template>
            <SvgIcon
              :style="{ fontSize: '20px' }"
              :name="loginType ? 'qrcodeOutlined' : 'desktopOutlined'"
            />
          </a-tooltip>
        </div>
        <FormLogin v-if="loginType" />
        <QrcodeLogin v-else />
      </div>
    </div>
    <div class="footer">{{ $t("web.com") }} &copy; 2019-2022</div>
  </div>
</template>

<style lang='less' scoped>
.login-container {
  width: 880px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;

  .header {
    width: 100%;
    padding-top: 20px;
    border-bottom: @border-width-base dashed @border-color-split;
    display: flex;
    justify-content: flex-start;
    align-items: center;

    .logo-img {
      width: 148px;
    }

    .slogn {
      border-left: @border-width-base solid @border-color-base;
      margin-left: 18px;
      padding-left: 18px;
      font-size: @heading-5-size;
      color: @text-color;
    }
  }

  .body {
    flex: none;
    display: flex;
    align-items: center;
    height: 420px;

    .carousel {
      flex: auto;
      border-radius: 20px;
      overflow: hidden;
    }

    .login-box {
      flex: none;
      box-sizing: border-box;
      margin-left: 20px;
      width: 368px;
      height: 100%;
      box-shadow: @box-shadow-base;
      padding: 50px 40px 20px;
      border-radius: 20px;

      .title-box {
        h2 {
          display: inline-block;
          margin-right: 10px;
        }

        .change-btn {
          color: @text-color-secondary;
          cursor: pointer;
        }
      }
    }
  }

  .footer {
    text-align: center;
    line-height: 64px;
    color: @text-color-third;
    font-size: @font-size-sm;
    border-top: @border-width-base dashed @border-color-split;
  }
}
@media screen and (max-width: 880px) {
  .login-container {
    width: 100%;

    .body {
      justify-content: center;
      .carousel {
        display: none;
      }
    }
  }
}

@media screen and (max-width: 500px) {
  .login-box {
    box-shadow: none !important;
  }
}
</style>